package cn.lichenfei.fxui.examples;

import cn.lichenfei.fxui.common.SimpleControl;
import cn.lichenfei.fxui.controls.CFCheckBox;
import cn.lichenfei.fxui.controls.CFRadioButton;
import cn.lichenfei.fxui.controls.CFSwitch;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;

// 表单组件
public class FormExample extends StackPane {

    GridPane gridPane = new GridPane();

    //
    public FormExample() {
        getChildren().add(gridPane);
        gridPane.setMaxHeight(Double.NEGATIVE_INFINITY);
        gridPane.setMaxWidth(Double.NEGATIVE_INFINITY);
        gridPane.setVgap(30);
        gridPane.setHgap(30);

        gridPane.add(SimpleControl.getLabel("单选框", SimpleControl.LabelEnum.H2), 0, 0, 3, 1);
        //单选框
        ToggleGroup tg = new ToggleGroup();
        CFRadioButton cfRadioButton1 = new CFRadioButton("单选框");
        cfRadioButton1.setToggleGroup(tg);
        CFRadioButton cfRadioButton2 = new CFRadioButton("单选框");
        cfRadioButton2.setSelected(true);
        cfRadioButton2.setToggleGroup(tg);
        CFRadioButton cfRadioButton3 = new CFRadioButton("单选框");
        cfRadioButton3.setToggleGroup(tg);
        gridPane.add(cfRadioButton1, 0, 1);
        gridPane.add(cfRadioButton2, 1, 1);
        gridPane.add(cfRadioButton3, 2, 1);

        gridPane.add(SimpleControl.getLabel("复选框", SimpleControl.LabelEnum.H2), 0, 2, 3, 1);
        //复选框
        CFCheckBox cfCheckBox1 = new CFCheckBox("复选框");
        CFCheckBox cfCheckBox2 = new CFCheckBox("复选框");
        CFCheckBox cfCheckBox3 = new CFCheckBox("复选框");
        cfCheckBox3.setSelected(true);
        gridPane.add(cfCheckBox1, 0, 3);
        gridPane.add(cfCheckBox2, 1, 3);
        gridPane.add(cfCheckBox3, 2, 3);

        gridPane.add(SimpleControl.getLabel("开关", SimpleControl.LabelEnum.H2), 0, 4, 3, 1);
        //开关组件
        CFSwitch cfSwitch1 = new CFSwitch();
        CFSwitch cfSwitch2 = new CFSwitch(true);
        CFSwitch cfSwitch3 = new CFSwitch();
        CFSwitch cfSwitch4 = new CFSwitch();
        gridPane.add(cfSwitch1, 0, 5);
        gridPane.add(cfSwitch2, 1, 5);
        gridPane.add(cfSwitch3, 2, 5);
        gridPane.add(cfSwitch4, 3, 5);

    }

}
